//
// RS Game Framework
// Copyright © 2009 Jedd Haberstro
// jhaberstro@gmail.com
// 
// $Id:
//

#include "rs/reflection/AttributeProperties.hpp"

namespace rs
{
    namespace reflection
    {
        AttributeProperties operator+(AttributeProperties const& lhs, AttributeProperties const& rhs) {
            RS_ASSERT(!(lhs.GetFriendlyName() && rhs.GetFriendlyName()), "Conflicting AttributeProperties friendly names");
            RS_ASSERT(!(lhs.GetDescription() && rhs.GetDescription()), "Conflicting AttributeProperties descriptions");
            
            AttributeProperties result(
                lhs.GetFriendlyName() ? lhs.GetFriendlyName() : rhs.GetFriendlyName(),
                lhs.GetDescription() ? lhs.GetDescription() : rhs.GetDescription()
            );
                        
            for(AttributeProperties::MetaDataContainerType::const_iterator itr = rhs.metaData_.begin(); itr != rhs.metaData_.end(); ++itr) {
                result.metaData_[itr->first] = itr->second;
            }
            
            for(AttributeProperties::MetaDataContainerType::const_iterator itr = lhs.metaData_.begin(); itr != lhs.metaData_.end(); ++itr) {
                RS_ASSERT(rhs.metaData_.find(itr->first) == rhs.metaData_.end(), "Attribute properties contain conflicting meta data entries");
                result.metaData_[itr->first] = itr->second;
            }
            
            return result;
        }
    }
}
